const drawCardUtils = {
  // 获得所有图片容器的初始坐标, name是容器的类名
  getAllRects: function (name) {
    return new Promise((resolve, reject) => {
      uni.createSelectorQuery().selectAll(name).boundingClientRect(function (rects) {
        resolve(rects);
      }).exec();
    });
  },
  // 获取图片容器大小, idx是容器id下标
  getFields: function (idx) {
    return new Promise((resolve, reject) => {
      const query = uni.createSelectorQuery().select(`#image${idx}`).fields({
        dataset: true,
        size: true,
      });
      query.exec(res => {
        resolve(res);
      });
    });
  },
  // 获取图片原始尺寸大小, picUrl图片路径
  getImgInfo: function (picUrl) {
    return new Promise((resolve, reject) => {
      uni.getImageInfo({
        src: picUrl,
        success: function (res) {
          resolve(res);
        }
      });
    });
  },
};
module.exports = drawCardUtils;